package com.geneticAlgorithm.wines;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class TestGA {
	public static void main(String[] args) throws IOException {

       
//		Grape malbec_1986 = new Grape("Malbec", 1986);
//		Grape cabernetSauvignon_1979 = new Grape("Cabernet Sauvignon", 1979);
//		Grape shyrah_1939 = new Grape("Shyrah", 1939);
//		Grape pinotNoir_1991 = new Grape("Pinot Noir", 1991);
//		Grape petitVerdot_1940 = new Grape("Petit Verdot", 1940);
//		Grape merlot_1988 = new Grape("Merlot", 1988);
		BufferedReader in = new BufferedReader(new FileReader("data.dat"));
		String line;
		while((line = in.readLine()) != null)
		{
			String[] values = line.split(",");
			String wineName = values[0];
			String grapeType = values[1];
			int grapeHarvest = Integer.parseInt(values[2]);
			
			WinesManager.addWine(new Wine(new Grape(grapeType,grapeHarvest),wineName));
		}
		
		in.close();

		
		
//        Wine wine = new Wine(malbec_1986,"Trumpeter");
//        WinesManager.addWine(wine);
//        Wine wine2 = new Wine(cabernetSauvignon_1979, "Calia");
//        WinesManager.addWine(wine2);
//        Wine wine3 = new Wine(shyrah_1939, "Elementos");
//        WinesManager.addWine(wine3);
//        Wine wine4 = new Wine(pinotNoir_1991, "Rutini");
//        WinesManager.addWine(wine4);
//        Wine wine5 = new Wine(petitVerdot_1940, "Lopez");
//        WinesManager.addWine(wine5);
//        Wine wine6 = new Wine(merlot_1988, "Don David");
//        WinesManager.addWine(wine6);
//        Wine wine7 = new Wine();
//        WinesManager.addWine(wine7);
//        Wine wine8 = new Wine();
//        WinesManager.addWine(wine8);
//        Wine wine9 = new Wine();
//        WinesManager.addWine(wine9);
//        Wine wine10 = new Wine();
//        WinesManager.addWine(wine10);
//        Wine wine11 = new Wine();
//        WinesManager.addWine(wine11);
//        Wine wine12 = new Wine();
//        WinesManager.addWine(wine12);
//        Wine wine13 = new Wine();
//        WinesManager.addWine(wine13);
//        Wine wine14 = new Wine();
//        WinesManager.addWine(wine14);
//        Wine wine15 = new Wine();
//        WinesManager.addWine(wine15);
//        Wine wine16 = new Wine();
//        WinesManager.addWine(wine16);
//        Wine wine17 = new Wine();
//        WinesManager.addWine(wine17);
//        Wine wine18 = new Wine();
//        WinesManager.addWine(wine18);
//        Wine wine19 = new Wine();
//        WinesManager.addWine(wine19);
//        Wine wine20 = new Wine();
//        WinesManager.addWine(wine20);

        // Initialize population
        Population pop = new Population(50, true);

        // Evolve population for 50 generations
        pop = GA.evolvePopulation(pop);
        for (int i = 0; i < 100; i++) {
            pop = GA.evolvePopulation(pop);
        }
        
        // Print final results
        System.out.println("Resultado:");
        System.out.println(pop.getFittest());
    }
}
